package com.alks.function.mapper.chengKong;

import com.alks.entity.data.entity.*;
import com.alks.function.data.dto.chengKong.assort.*;
import com.alks.function.data.dto.procurement.CleanDataDto;
import com.alks.function.data.dto.procurement.SdBomFitSubDto;
import com.alks.function.data.request.chengKong.CopyingDosageQueryRequest;
import com.alks.function.data.request.chengKong.FullCodeRenewGetRequest;
import com.alks.function.data.request.chengKong.FullCodeRequest;
import com.alks.function.data.request.chengKong.UsageDetailsQueryChangeRequest;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface LargeCargoUsageMapper {

    /**
     * 查询基本
     * @param styleNo
     * @param styleColor
     * @return
     */
    @Select("SELECT * FROM YF_BOM_HEAD_NEW2 WHERE STYLE_NO=#{styleNo} AND STYLE_COLOR=#{styleColor}")
    YfBomHeadNew2 getYfBomHeadNew(@Param("styleNo") String styleNo,
                                  @Param("styleColor") String styleColor);

    /**
     * 查询是否存在
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Select("select * from SD_BOM_HEAD_NEW2 WHERE STYLE_NO=#{styleNo} AND STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId} limit 1")
    SdBomHeadNew2 sdBomHeadNew2(@Param("styleNo") String styleNo,
                                @Param("styleColor") String styleColor,
                                @Param("companyId") String companyId);

    /**
     * 新增
     * @param sdBomHeadNew2
     */
    @Insert("insert into SD_BOM_HEAD_NEW2(COMPANY_ID,STYLE_NO,STYLE_COLOR,SYS_USER,SYS_DATE,BASE_SIZE,COLOR_CODE)values " +
            "(#{companyId},#{styleNo},#{styleColor},#{sysUser},#{sysDate},#{baseSize},#{colorCode})")
    void addSdBomHeadNew2(SdBomHeadNew2 sdBomHeadNew2);

    /**
     * 新增
     * @param list
     */
    @Insert({
            "<script>",
            "insert into SD_BOM_PART_NEW2(COMPANY_ID,STYLE_NO,STYLE_COLOR,SEQ_NO,PART_NAME,SEGMENT,MTL_NO,MTL_NAME,MTL_COLOR,MTL_SPEC,MTL_UNIT,`USAGE`,USAGE_TYPE" +
                    ",VENDOR,SIZE1,SIZE2,MTL_TYPE_NO,MTL_NO2,DRAW_DEPT,MTL_PROPERTY,NO_LOT_USAGE,REMARK)",
            "values ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.companyId},#{item.styleNo},#{item.styleColor},#{item.seqNo},#{item.partName},#{item.segment},#{item.mtlNo},#{item.mtlName},#{item.mtlColor}," +
                    "#{item.mtlSpec},#{item.mtlUnit},#{item.usage},#{item.usageType},#{item.vendor},#{item.size1},#{item.size2},#{item.mtlTypeNo},#{item.mtlNo2},#{item.drawDept}," +
                    "#{item.mtlProperty},#{item.noLotUsage},#{item.remark})",
            "</foreach>",
            "</script>"
    })
    void addSdBomPartNew2List(@Param("list") List<SdBomPartNew2> list);

    /**
     * 删除贴合材料
     * @param mtlNo
     * @param companyId
     * @return
     */
    @Delete("delete from SD_BOM_FIT_SUB where MTL_NO=#{mtlNo} and COMPANY_ID=#{companyId}")
    int delSdBomFitSub(@Param("mtlNo") String mtlNo,
                                     @Param("companyId") String companyId);
    /**
     * 查询贴合材料
     * @param mtlNo2
     * @return
     */
    @Select("select * from  YF_BOM_FIT_SUB where MTL_NO=#{mtlNo2}")
    List<YfBomFitSub> getYfBomFitSub(String mtlNo2);

    /**
     * 添加到SD_BOM_FIT_SUB
     * @param sdBomFitSubs
     */
    @Insert("<script>" +
            "insert into SD_BOM_FIT_SUB(COMPANY_ID,MTL_NO,MTL_COLOR,MTL_NAME,MTL_SPEC,MTL_UNIT,SUB_MTL_NO,SUB_MTL_COLOR,SUB_MTL_NAME,SUB_MTL_SPEC," +
            "SUB_MTL_UNIT,PRD_TYPE,PERCENT,PUR_FLAG,SYS_USER,MTL_SEQ) values" +
            "<foreach collection='sdBomFitSubs' item='t' separator=','>" +
            "(#{t.companyId},#{t.mtlNo},#{t.mtlColor},#{t.mtlName},#{t.mtlSpec},#{t.mtlUnit}," +
            "#{t.subMtlNo},#{t.subMtlColor},#{t.subMtlName},#{t.subMtlSpec},#{t.subMtlUnit}," +
            "#{t.prdType},#{t.percent},#{t.purFlag},#{t.sysUser},#{t.mtlSeq})" +
            "</foreach>" +
            "</script>")
    void addSdBomFitSubList(@Param("sdBomFitSubs") List<SdBomFitSub> sdBomFitSubs);

    /**
     * 添加到SD_BOM_USAGE_NEW2
     * @param usageNew2List
     */
    @Insert({
            "<script>",
            "insert into SD_BOM_USAGE_NEW2(COMPANY_ID,STYLE_NO,STYLE_COLOR,PART_NAME,SEGMENT,MTL_NO,USAGE_TYPE,SIZE_FROM," +
                    "SIZE_TO,MTL_USAGE,SEQ_NO)",
            "values ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.companyId},#{item.styleNo},#{item.styleColor},#{item.partName},#{item.segment},#{item.mtlNo},#{item.usageType}," +
                    "#{item.sizeFrom},#{item.sizeTo},#{item.mtlUsage},#{item.seqNo})",
            "</foreach>",
            "</script>"
    })
    void addSdBomUsageNew2List(List<SdBomUsageNew2> usageNew2List);

    /**
     * 型体查询
     * @param request
     * @return
     */
    @Select({
            "<script>",
            "select STYLE_NO from SD_BOM_HEAD_NEW2",
            "<where>",
            "and COMPANY_ID=#{companyId}",
            "<if test='styleNo != null and !styleNo.isEmpty()'>",
            "AND STYLE_NO LIKE CONCAT('%',#{styleNo},'%') ",
            "</if>",
            "<if test='styleColor != null and !styleColor.isEmpty()'>",
            "AND STYLE_COLOR LIKE CONCAT('%',#{styleColor},'%')",
            "</if>",
            "<if test='colorCode != null and !colorCode.isEmpty()'>",
            "AND COLOR_CODE LIKE CONCAT('%',#{colorCode},'%')",
            "</if>",
            "</where>",
            "group by STYLE_NO order by SYS_DATE desc ",
            "</script>",
    })
    List<String> getDevelopBomList(UsageDetailsQueryChangeRequest request);

    /**
     * 型体颜色图片
     * @param request
     * @return
     */
    @Select({
            "<script>",
            "SELECT a.STYLE_NO,a.STYLE_COLOR,a.COLOR_CODE,t.PHOTO_PATH,a.BASE_SIZE as remark,a.CFM_FLAG,a.COMPANY_ID from(SELECT COMPANY_ID,STYLE_NO,STYLE_COLOR,COLOR_CODE,CFM_FLAG,BASE_SIZE from SD_BOM_HEAD_NEW2 )a LEFT JOIN  ",
            "SD_STYLE_COLOR_PHOTO t on a.STYLE_NO=t.STYLE_NO and a.STYLE_COLOR=t.STYLE_COLOR AND a.COMPANY_ID=t.COMPANY_ID",
            "<where>",
            "a.STYLE_NO = #{styleNo} and a.COMPANY_ID=#{companyId}",
            "<if test='styleColor != null and !styleColor.isEmpty()'>",
            "AND a.STYLE_COLOR = #{styleColor}",
            "</if>",
            "<if test='colorCode != null and !colorCode.isEmpty()'>",
            "AND a.COLOR_CODE = #{colorCode}",
            "</if>",
            "</where>",
            "</script>",
    })
    List<StyleToPhotoDto> getDevelopBomPhotoList(UsageDetailsQueryChangeRequest request);

    /**
     * 用量明细资料查询
     * @param styleNo
     * @param styleColor
     * @param companyId
     * @return
     */
    @Select({
            "<script>",
            "SELECT a.STYLE_NO,a.STYLE_COLOR,t.TYPE_NAME,a.SEQ_NO,a.PART_NAME,a.SEGMENT,a.mtlNo,a.MTL_NAME,a.MTL_COLOR,a.MTL_SPEC,a.MTL_UNIT,",
            "a.SIZE1,a.SIZE2,a.VENDOR,a.`USAGE`,a.USAGE_TYPE,a.DRAW_DEPT,a.MTL_PROPERTY,a.NO_LOT_USAGE,a.REMARK,a.MTL_TYPE_NO,a.COMPANY_ID from ",
            "(SELECT COMPANY_ID,STYLE_NO,STYLE_COLOR,SEQ_NO,PART_NAME,SEGMENT,MTL_NO2 as mtlNo,MTL_NAME,MTL_COLOR,MTL_SPEC,MTL_UNIT,SIZE1,SIZE2,VENDOR,",
            "`USAGE`,USAGE_TYPE,DRAW_DEPT,MTL_PROPERTY,NO_LOT_USAGE,REMARK,MTL_TYPE_NO from SD_BOM_PART_NEW2) a",
            "LEFT JOIN SD_MTL_TYPE_NEW t ON a.MTL_TYPE_NO = t.TYPE_NO WHERE a.STYLE_NO =#{styleNo} AND a.STYLE_COLOR =#{styleColor} and a.COMPANY_ID=#{companyId}  ORDER BY a.SEQ_NO asc",
            "</script>",
    })
    List<YfBomPartNew2Dto> getDevelopBomUsageList(@Param("styleNo") String styleNo,
                                                  @Param("styleColor") String styleColor,
                                                  @Param("companyId") String companyId);

    /**
     * 查询所有用量明细资料查询
     * @param styleNo
     * @param styleColor
     * @param companyId
     * @return
     */
    @Select("SELECT * from SD_BOM_PART_NEW2 where STYLE_NO =#{styleNo} AND STYLE_COLOR =#{styleColor} and COMPANY_ID=#{companyId} ORDER BY SEQ_NO asc")
    List<SdBomPartNew2> getSdBomPartNew2List(@Param("styleNo") String styleNo,
                                             @Param("styleColor") String styleColor,
                                             @Param("companyId") String companyId);

    /**
     * 检核
     * @param styleNo
     * @param styleColor
     * @param userName
     * @param companyId
     * @param cfmFlag
     * @param now
     */
    @Update("update SD_BOM_HEAD_NEW2 set CFM_FLAG=#{cfmFlag}, CFM_USER=#{userName}, CFM_DATE=#{now} where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void updateSdBomCheckOut(@Param("styleNo")String styleNo,
                             @Param("styleColor")String styleColor,
                             @Param("userName") String userName,
                             @Param("companyId") String companyId,
                             @Param("cfmFlag") String cfmFlag,
                             @Param("now") LocalDateTime now);

    /**
     * 添加注意事项
     * @param sdBomMemoNew2s
     */
    @Insert({
            "<script>",
            "insert into SD_BOM_MEMO_NEW2(COMPANY_ID,STYLE_NO,STYLE_COLOR,SEQ_NO,PROD_MEMO,SEQ_NAME)",
            "values ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.companyId},#{item.styleNo},#{item.styleColor},#{item.seqNo},#{item.prodMemo},#{item.seqName})",
            "</foreach>",
            "</script>"
    })
    void addSdBomMemoNew2(@Param("list") List<SdBomMemoNew2> sdBomMemoNew2s);

    /**
     * 注意事项建档列表
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Select("select SEQ_NO,SEQ_NAME,PROD_MEMO from SD_BOM_MEMO_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId} order by SEQ_NO")
    List<YfBomMemoNew2Dto> getNotesForFilingList(@Param("styleNo") String styleNo,
                                                 @Param("styleColor") String styleColor,
                                                 @Param("companyId") String companyId);

    /**
     * 删除注意事项
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Delete("delete from SD_BOM_MEMO_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void delNotesForFiling(@Param("styleNo") String styleNo,
                           @Param("styleColor") String styleColor,
                           @Param("companyId") String companyId);

    /**
     * 用量明细资料删除
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Delete("delete from SD_BOM_PART_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void delDevelopBomUsage(@Param("styleNo") String styleNo,
                            @Param("styleColor") String styleColor,
                            @Param("companyId") String companyId);

    /**
     * 修改型体基本号
     * @param baseSize
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Update("update SD_BOM_HEAD_NEW2 set BASE_SIZE=#{baseSize} where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void updateBaseSize(@Param("baseSize") String baseSize,
                        @Param("styleNo") String styleNo,
                        @Param("styleColor") String styleColor,
                        @Param("companyId") String companyId);

    /**
     * 修改用量明细资料
     * @param bomPartNew2
     */
    @Update("update SD_BOM_PART_NEW2 set  PART_NAME=#{partName},MTL_NO=#{mtlNo},MTL_NAME=#{mtlName},MTL_COLOR=#{mtlColor}," +
            "MTL_SPEC=#{mtlSpec},MTL_UNIT=#{mtlUnit},VENDOR=#{vendor},MTL_NO2=#{mtlNo2},USAGE_TYPE=#{usageType},DRAW_DEPT=#{drawDept}," +
            "MTL_PROPERTY=#{mtlProperty} where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and SEQ_NO=#{seqNo}")
    void updateBomMaterial(SdBomPartNew2 bomPartNew2);

    /**
     * 查询用量明细资料段
     * @param styleNo
     * @param styleColor
     * @param partName
     * @return
     */
    @Select("select SEGMENT from SD_BOM_PART_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor}" +
            "and PART_NAME=#{partName}")
    List<String> getSdBomPartSegment(@Param("styleNo")String styleNo,
                                    @Param("styleColor")String styleColor,
                                    @Param("partName") String partName);

    /**
     * 单个添加
     * @param bomPartNew2
     */
    @Insert("insert into SD_BOM_PART_NEW2(COMPANY_ID,STYLE_NO,STYLE_COLOR,SEQ_NO,PART_NAME,SEGMENT,MTL_NO,MTL_NAME,MTL_COLOR,MTL_SPEC,MTL_UNIT,`USAGE`,USAGE_TYPE" +
            ",VENDOR,SIZE1,SIZE2,MTL_TYPE_NO,MTL_NO2,DRAW_DEPT,MTL_PROPERTY,NO_LOT_USAGE,REMARK) values "+
            "(#{companyId},#{styleNo},#{styleColor},#{seqNo},#{partName},#{segment},#{mtlNo},#{mtlName},#{mtlColor},#{mtlSpec},#{mtlUnit},#{usage},#{usageType}," +
            "#{vendor},#{size1},#{size2},#{mtlTypeNo},#{mtlNo2},#{drawDept},#{mtlProperty},#{noLotUsage},#{remark})")
    void addBomMaterial(SdBomPartNew2 bomPartNew2);

    /**
     * 删除型体打勾记录
     * @param styleNo
     * @param styleColor
     * @param seqNoList
     */
    @Delete({
            "<script>",
            "delete from SD_BOM_PART_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId} and SEQ_NO IN",
            "<foreach collection='seqNoList' item='seqNo' separator=',' open='(' close=')'>",
            "#{seqNo}",
            "</foreach>",
            "</script>"
    })
    void deleteTickRecords(@Param("styleNo")String styleNo,
                           @Param("styleColor")String styleColor,
                           @Param("companyId")String companyId,
                           @Param("seqNoList") List<BigDecimal> seqNoList);

    /**
     * 复制用量列表
     * @param request
     * @return
     */
    @Select({
            "<script>",
            "SELECT t.STYLE_NO,t.STYLE_COLOR,MIN(a.CUT_SIZE) minCutSize,MAX(a.CUT_SIZE) maxCutSize,t.CFM_FLAG,t.COMPANY_ID from (SELECT COMPANY_ID,STYLE_NO,STYLE_COLOR,CFM_FLAG FROM " +
                    "SD_BOM_HEAD_NEW2)t LEFT JOIN SD_STYLE_SIZE a on t.STYLE_NO=a.STYLE_NO",
            "<where>",
            "and t.COMPANY_ID=#{companyId}",
            "<if test='styleNo != null and !styleNo.isEmpty()'>",
            "<if test='styleNo.equals(currentStyleNo)'>",
            "AND t.STYLE_NO LIKE CONCAT('%', #{styleNo}, '%')",
            "AND t.STYLE_COLOR != #{currentStyleColor}",
            "</if>",
            "<if test='!styleNo.equals(currentStyleNo)'>",
            "AND t.STYLE_NO != #{currentStyleNo}",
            "AND t.STYLE_COLOR != #{currentStyleNo}",
            "AND t.STYLE_NO LIKE CONCAT('%', #{styleNo}, '%')",
            "</if>",
            "</if>",
            "<if test='styleNo == null and styleNo.isEmpty()'>",
            "AND t.STYLE_NO != #{currentStyleNo}",
            "AND t.STYLE_COLOR != #{currentStyleColor}",
            "</if>",
            "</where>",
            "GROUP BY t.STYLE_NO,t.STYLE_COLOR",
            "</script>"
    })
    List<CopyingDosageListDto> getCopyingDosageList(CopyingDosageQueryRequest request);

    /**
     * 查询冲刀号码
     * @param styleNo
     * @param companyId
     * @return
     */
    @Select("SELECT CUT_SIZE from SD_STYLE_SIZE where STYLE_NO=#{styleNo} and COMPANY_ID=#{companyId} order by SEQ_NO")
    List<String> getTypeSize(@Param("styleNo") String styleNo, @Param("companyId") String companyId);

    /**
     * 修改用量明细资料用量
     * @param updatedList
     */
    @Update({
            "<script>",
            "<foreach collection='updatedList' item='t' separator=';'>",
            "update SD_BOM_PART_NEW2 set `USAGE`=#{t.usage},USAGE_TYPE=#{t.usageType} where STYLE_NO=#{t.styleNo} and STYLE_COLOR=#{t.styleColor} and PART_NAME=#{t.partName} and SEGMENT=#{t.segment} and COMPANY_ID=#{t.companyId}",
            "</foreach>",
            "</script>"
    })
    void updateBomCopyingDosage(List<YfBomPartNew2Dto> updatedList);

    /**
     * 删除型体建档
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Delete("delete from SD_BOM_HEAD_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void delBomHead(@Param("styleNo") String styleNo,
                    @Param("styleColor") String styleColor,
                    @Param("companyId") String companyId);

    /**
     * 删除全码资料
     * @param styleNo
     * @param styleColor
     * @param companyId
     */
    @Delete("delete from SD_BOM_USAGE_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId}")
    void delBomUsage(@Param("styleNo") String styleNo,
                     @Param("styleColor") String styleColor,
                     @Param("companyId") String companyId);

    /**
     * 查询全码用量资料
     * @param request
     */
    @Select("select COMPANY_ID,STYLE_NO,STYLE_COLOR,PART_NAME,SEGMENT,SIZE_FROM,MTL_USAGE from SD_BOM_USAGE_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and PART_NAME=#{partName}" +
            "and SEGMENT=#{segment} and COMPANY_ID=#{companyId} order by SIZE_FROM")
    List<SdBomUsageNew2> getFullCodeSizeList(FullCodeRenewGetRequest request);

    /**
     * 删除全码用量资料
     * @param styleNo
     * @param styleColor
     * @param list
     * @param companyId
     */
    @Delete({
            "<script>",
            "delete from SD_BOM_USAGE_NEW2 where STYLE_NO=#{styleNo} and STYLE_COLOR=#{styleColor} and COMPANY_ID=#{companyId} " +
                    "<foreach collection='list' item='t' separator=','>",
            "and PART_NAME=#{t.partName} and SEGMENT=#{t.segment} and SIZE_FROM=#{t.sizeFrom}",
            "</foreach>",
            "</script>",
    })
    void delFullCodeSize(@Param("styleNo") String styleNo,
                         @Param("styleColor") String styleColor,
                         @Param("list") List<FullCodeRequest> list,
                         @Param("companyId") String companyId);

    /**
     * 贴合子材料明细
     * @param mtlNo
     * @param companyId
     */
    @Select("SELECT t.TYPE_NAME as colorCode,a.SUB_MTL_NO as mtlNo,a.mtlName,a.mtlColor,a.mtlSpec,a.mtlUnit,a.PRD_TYPE,a.PERCENT,a.PUR_FLAG,a.MTL_SEQ from " +
            "(select COMPANY_ID,MTL_NO,SUB_MTL_NO,SUB_MTL_NAME as mtlName,SUB_MTL_COLOR as mtlColor,SUB_MTL_SPEC as mtlSpec,SUB_MTL_UNIT as mtlUnit,PRD_TYPE,PERCENT," +
            "PUR_FLAG,MTL_SEQ,SUBSTRING( SUB_MTL_NO, 1, 2) AS typeNo from SD_BOM_FIT_SUB) a LEFT JOIN SD_MTL_TYPE_NEW t ON a.typeNo = t.TYPE_NO  " +
            "where a.MTL_NO=#{mtlNo} and a.COMPANY_ID=#{companyId} order by a.MTL_SEQ")
    List<YfSubMtlTemp2Dto> getDetailsOfAdhesiveSubMaterial(@Param("mtlNo") String mtlNo,
                                                           @Param("companyId") String companyId);

    /**
     * 贴合子材料-修改
     *
     * @param mtlNo
     * @param mtlSeq
     * @param flag
     * @param companyId
     * @param percent
     * @param userName
     */
    @Update("update SD_BOM_FIT_SUB set PUR_FLAG=#{flag} ,PERCENT=#{percent},UPDATE_USER=#{userName},UPDATE_DATE=now() where MTL_NO=#{mtlNo} and MTL_SEQ=#{mtlSeq} and COMPANY_ID=#{companyId}")
    void UpdateDetailsOfAdhesiveSubMaterial(@Param("mtlNo")String mtlNo,
                                            @Param("mtlSeq")String mtlSeq,
                                            @Param("flag")String flag,
                                            @Param("companyId")String companyId,
                                            @Param("percent") String percent,
                                            @Param("userName") String userName);

    /*贴合子材料明细*/
    List<SdBomFitSubDto> getDetailsOfAdhesiveSubMaterialBymtlNoList(@Param("mtlNoList") Collection<String> mtlNoList, @Param("companyId") String companyId, @Param("lotNo") String lotNo);

    /*贴合子材料明细*/
    List<SdBomFitSubDto> getPcLotUsageFit(String companyId, String lotNo);

    /**
     * 物料编码查询
     * @return
     */
    @Select("select TYPE_NO as typeNo,TYPE_NAME as typeName from SD_MTL_TYPE_NEW")
    List<Map<String,String>> getTypeNoList();

    /**
     * 写入部位差异日志
     * @param pcDiffParts
     * @return
     */
    int addPcDiffPartList(@Param("list") List<PcDiffPart> pcDiffParts);

    /**
     * 删除整个型体日志
     * @param styleNo
     * @param styleColor
     * @return
     */
    int delPcDiffPart(@Param("companyId") String companyId,@Param("styleNo") String styleNo, @Param("styleColor") String styleColor);

    /*清洗SD_BOM_FIT_SUB数据*/
    int cleanSdBomFitSub(String companyId, List<CleanDataDto> list);

    /*清洗YF_BOM_FIT_SUB数据*/
    int cleanYFBomFitSub(Object o, List<CleanDataDto> list);

    /*/*清洗PC_LOT_USAGE_FIT_CHG数据*/
    int cleanPcLotUsageFitChg(String lotNo, List<CleanDataDto> list);

    /*有的话清洗MP_PUR_DIS*/
    int cleanMpPurDis(String lotNo, List<CleanDataDto> list);

    /*有的话清洗PC_LOT_USAGE_CHG*/
    int cleanPcLotUsageChg(String lotNo, List<CleanDataDto> list);

    /**
     * 查询贴合子料
     * @param mtlNo
     * @param mtlSeq
     * @param companyId
     * @return
     */
    @Select("select * from SD_BOM_FIT_SUB where MTL_NO=#{mtlNo} and MTL_SEQ=#{mtlSeq} AND COMPANY_ID=#{companyId}")
    SdBomFitSub getSdBomFitSub2(@Param("mtlNo") String mtlNo, @Param("mtlSeq") String mtlSeq, @Param("companyId") String companyId);

    /**
     * 添加修改请购日志记录
     * @param subLog
     */
    @Insert("insert into SD_BOM_FIT_SUB_LOG(COMPANY_ID,MTL_NO,MTL_COLOR,MTL_NAME,MTL_SPEC,MTL_UNIT,SUB_MTL_NO,SUB_MTL_COLOR,SUB_MTL_NAME,SUB_MTL_SPEC," +
            "SUB_MTL_UNIT,PRD_TYPE,PERCENT,PUR_FLAG,SYS_USER,SYS_DATE,MTL_SEQ,REMARK) values (#{companyId},#{mtlNo},#{mtlColor},#{mtlName},#{mtlSpec}," +
            "#{mtlUnit},#{subMtlNo},#{subMtlColor},#{subMtlName},#{subMtlSpec},#{subMtlUnit},#{prdType},#{percent},#{purFlag},#{sysUser},#{sysDate},#{mtlSeq},#{remark})")
    int addSdBomFitSubLog(YfBomFitSubLog subLog);

}

